fp = open('text.txt', 'w')
print('hello world!!', file=fp)
fp.close()

rf = open('text.txt', 'r')
s = rf.read()
print(s)